home *** CD-ROM | disk | FTP | other *** search
/ PCMania 64 / PCMania CD64_1.iso / phy / phy001 / lowlevel / julia.c next >
Encoding:
C/C++ Source or Header  |  1995-09-21  |  959 b   |  61 lines

  1. //  Fractal de JULIA.
  2.  
  3. #include <dos.h>
  4. #include <conio.h>
  5. #include <stdio.h>
  6.  
  7. #define NPH 320
  8. #define NPV 200
  9.  
  10. void punto(int x,int y, int c)
  11. {
  12.  pokeb(0xA000, (y*320)+x, (unsigned char) c);
  13.  }
  14.  
  15. int main(void)
  16. {
  17.  float a,b;
  18.  float x1=0;
  19.  float x2=1;
  20.  float y1=0;
  21.  float y20,y2=1;
  22.  float x,y,xx;
  23.  float vanox,vanoy;
  24.  int j,k,n;
  25.  
  26.  printf("Escribe los valores de 'a' y 'b'\n");
  27.  scanf("\n%e",&a);
  28.  scanf("\n%e",&b);
  29.  
  30.  //asm  mov ax,0x13;
  31.  //asm  int 0x10;
  32.  
  33.  vanox=(x2-x1)/NPH;
  34.  vanoy=(y2-y1)/NPV;
  35.  
  36.  for(k=0;k<NPH;k++)
  37.   {
  38.    x1+=vanox;
  39.    y20=y2;
  40.    for(j=0;j<NPV;j++)
  41.     {
  42.      y20+=vanoy; y=y20; 
  43.      x=x1; n=0;
  44.      while(n<100 && x*x+y*y<100)
  45.       {
  46.        xx=x*x-y*y+a;
  47.        y=2*x*y+b;
  48.        x=xx; n++;
  49.        printf("X=%f  Y=%f\n",x,y);
  50.        }
  51.      if(x*x+y*y>100) punto(k,j,n);
  52.      }
  53.    }
  54.  asm  mov ax,0x93;
  55.  asm  int 0x10;
  56.  while(!kbhit);
  57.  
  58.  asm  mov ax,3;
  59.  asm  int 0x10;
  60.  return 0;
  61.  }